﻿package we3d.renderer.realistic 
{
	import we3d.View3d;
	import we3d.core.Camera3d;
	import we3d.scene.SceneObject;
	import we3d.math.Matrix3d;
	import we3d.renderer.IRenderer
	
	/**
	* The CustomCull renderer allows to set individual culling/clipping per SceneObject.
	*/
	public class CustomCull implements IRenderer 
	{
		public function CustomCull () {}
		
		public function draw (view:View3d) :void {
			
			var f:Number = view.scene.currentFrame;
			var v:Camera3d = view.scene.cam;
			var objectList:Array = view.scene.objectList;
			var L:int = objectList.length;
			var cgv:Matrix3d = new Matrix3d();
			var o:SceneObject;
			var i:int;
			
			view.initFrame(f);
			
			for(i=0; i<L; i++) {
				
				o = objectList[i];
				if(o.initFrame(f, v, cgv)) continue;
				if(o.initMesh(view, cgv)) continue;
				
				o.objectRenderer.render(view, o, cgv);
			}
			
			view.endFrame(f);
		}
		
	}
}